﻿using System;
using System.Configuration;
using MSAcademic.v2.Infrastructure.Login;
using MSAcademic.v2.Infrastructure.Picture;
using MSAcademic.v2.Infrastructure.User;

namespace MSAcademic.v2.Web.Areas.Admin.Models.Picture
{
    public partial class EditUserProfilePictureViewModel
    {
        public string CropedPictureUrl { get; set; }
        public string OriginalUrl { get; set; }
    }
    public partial class EditUserProfilePictureViewModel
    {
        public string PictureUrl
        {
            get
            {
                if (_pictureUrl == null)
                {
                    _pictureUrl = new Lazy<string>(() => _pictureService.GetOriginalPictureUrl(SignedInUser.ProfilePictureUrl));
                }
                return _pictureUrl.Value;
            }
        }
        private Lazy<string> _pictureUrl;
        public IUser SignedInUser
        {
            get
            {
                if (_signedInUser == null)
                {
                    _signedInUser = new Lazy<IUser>(() => _loginService.TryGetSignedInUser());
                }
                return _signedInUser.Value;
            }
        }
        private Lazy<IUser> _signedInUser;
        public int ProfilePicWidth
        {
            get { return Convert.ToInt32(ConfigurationManager.AppSettings["UserProfilePictureCropedWidth"]); }
        }
        
    }
    public partial class EditUserProfilePictureViewModel
    {
        private readonly ILoginService _loginService;
        private readonly IPictureService _pictureService;
        public EditUserProfilePictureViewModel(ILoginService loginService,
            IPictureService pictureService)
        {
            _loginService = loginService;
            _pictureService = pictureService;
        }
    }
}